package top.i89ck.modules.utils;

import java.util.Objects;

/**
 * 分页数据的类
 *
 * @author Administrator
 */
public class Pager {

    private Integer pageNum;
    private Integer pageSize;

    /**
     * 针对jqgrid的当前页
     */
    private Integer page;

    /**
     * 针对jqgrid的每页数
     */
    private Integer rows;

    private int toInt(Integer arg0) {
        if (Objects.isNull(arg0)) {
            return 0;
        }
        return arg0;
    }

    public Integer getPageNum() {
        return toInt(pageNum) > 0 ? pageNum : 1;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return toInt(pageSize) > 0 ? pageSize : 20;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public void setPage(Integer page) {
        this.page = page;
        this.pageNum = this.page;
    }

    public void setRows(Integer rows) {
        this.rows = rows;
        this.pageSize = this.rows;
    }

}
